//
//  CocoaMeshAppDelegate.m
//  CocoaMesh
//
//  Created by George  Armah on 4/27/09.
//  Copyright Lafayette College 2009. All rights reserved.
//

#import "CocoaMeshAppDelegate.h"
#import "RootViewController.h"
#import "CMCocoaMesh.h"


@implementation CocoaMeshAppDelegate

@synthesize window;
@synthesize navigationController;


- (void)applicationDidFinishLaunching:(UIApplication *)application 
{
	
	// Configure and show the window
	[window addSubview:[navigationController view]];
	[window makeKeyAndVisible];
	
	CMLOE * loe = [[CMLOE alloc] init];
	
	[loe connectWithUserID:@"" 
				  password:@"" 
			 applicationID:@"" 
		   connectionError:nil];
	
	NSArray * arr = [loe loadMeshObjects:nil];
	
	NSError * err= nil;
	[loe createMeshObject:&err];
	
	NSArray * arr2 = [loe loadMeshObjects:nil];

	//NSLog(@"Number of old mesh objects is %i \n\n\n number of new mesh objects is %i \n", [arr count], [arr2 count]);
	
	NSMutableSet * set1 = [NSMutableSet setWithArray:arr];
	NSMutableSet * set2 = [NSMutableSet setWithArray:arr2];
	
	NSLog(@"Set 1 is of size:%i  Set 2 is of size %i. \n\n\n Set 1 intersects Set 2 is %i", [set1 count], [set2 count], [set1 intersectsSet:set2]);
	NSLog(@"Doing Set 2 = Set 2 - Set 1");
	
	[set2 minusSet:set1];
	
	NSLog(@"Set 1 is of size:%i  Set 2 is of size %i. \n\n\n Set 1 intersects Set 2 is %i", [set1 count], [set2 count], [set1 intersectsSet:set2]);
	[loe release];
}


- (void)applicationWillTerminate:(UIApplication *)application 
{
	// Save data if appropriate
}


- (void)dealloc 
{
	[navigationController release];
	[window release];
	[super dealloc];
}

@end
